package com.fundedu;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class FundEduServlet extends HttpServlet {
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		String userName=req.getParameter("username");
		String userPassword=req.getParameter("userpassword");
		
		Properties defaultProps = new Properties();

		InputStream inputStream = getServletContext().getResourceAsStream("/WEB-INF/login.properties");
		defaultProps.load(inputStream);
		if(userName!=null && userPassword!=null )
		{
			if(userName.equals(defaultProps.getProperty("username"))&& userPassword.equals(defaultProps.getProperty("password")))
			{
				resp.sendRedirect("/fundedu/homepage.jsp");	
			}
		}
		else
			resp.sendRedirect("/fundedu/login");
	}
}
